<%@ include file="/WEB-INF/jsp/includes.jsp" %>
<%@ include file="/WEB-INF/jsp/header.jsp" %>

<head>
<script language="JavaScript">
//Chuck
function doSubmit(){
	dojo.xhrPost({
		
		form: "findOwners",
		
		 handleAs: "json", //But we want to be able to use eval, based on having a 
		                  //response header of "EXPECT_JSON", and to sometimes have text
		                  //as well, as with the fancy Spring.js redirects in the Spring-dojo.js
		                  //remoting response handler.
		
		//headers: {"Accept" : "text/html;type=ajax"},
		
        load: function(data, ioargs) {
			//Value is true: alert(ioargs.xhr.getResponseHeader('EXPECT_JSON_CONTENT'))
			//var json = eval(data)
			if(data.redirectURL !== undefined){
				window.location = window.location.protocol + "//" + window.location.host + data.redirectURL;
				return data
			}
			//showPartials(data) 
			$.doPartialsAndJS(data) 
		
		        //alert(ioargs.xhr.getResponseHeader('hey'));
		        //alert(ioargs.xhr.getResponseHeader('well'));
		        //alert(data)
		       /* if(ioargs.xhr.getResponseHeader('VALIDATION_FAILED'))
		        	dojo.byId('main').innerHTML = data;  
		        else  
		        	dojo.byId('owners').innerHTML = data;
        	*/
        },

        error: function(type, err) {
            alert(err)
	    	alert("Error communicating with server. Mostlikely this means your session has timed out")
        }
    });
  }

 $(function() {
  $.addIds($('form')[0])
 });

</script>
</head>
<h2>Find Owners:</h2>

<form:form id="findOwners"  modelAttribute="owner">
   <!-- THIS IS THE ONLY STUFF YOU NEED TO CHECK the addIds javascript function.
        It must be inside a form.
        The one named yowzer shouldn't get an id of yowzer because there's another element
        with the yowzer id.  The one named x with id yowzer should keep those attributes.
        The first one named p should gain an id of p.  The second one named p should not
        gain any id. -->
   <input  name="yowzer" type="text" value="" size="30" maxlength="80"/>

   <input  name="x" id="yowzer" type="text" value="" size="30" maxlength="80"/>

   <input  name="p"  type="text" value="" size="30" maxlength="80"/>
   <input  name="p"  type="text" value="" size="30" maxlength="86"/>
  <table>
    <tr>
      <th>
        Last Name: <form:errors path="*" cssClass="errors"/>
        <br/> 
        <form:input path="lastName" id="lastName" size="30" maxlength="80"/>
      </th>
    </tr>
    <tr>
      <!--Chuck -->
      <td><p class="submit"><input type="submit" value="Find Owners" onclick="doSubmit();return false;"></p></td>
      <!-- 
      <td><p class="submit"><input type="submit" value="Find Owners" ></p></td>
     -->
    </tr>
  </table>
</form:form>

<br/>
<a href="<c:url value="/addOwner.do"/>">Add Owner</a>
<div id='jsPartial'></div>
<%@ include file="/WEB-INF/jsp/footer.jsp" %>
